﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeviceManager.DataAccessLayer
{
    public class CountryDbOperation:IDatabaseOperation<NUOC>
    {

        QLThietBiEntities devicemanager;
        #region IDatabaseOperation<T> Members

        public int SaveRecord(NUOC record)
        {
            try
            {
                using (devicemanager = new QLThietBiEntities())
                {
                    devicemanager.NUOCs.Add(record);
                    devicemanager.SaveChanges();
                }
                return (int)record.NuocID;
            }
            catch
            {
                return -1;
            }
        }
        #endregion

        public bool UpdateRecord(NUOC record)
        {
            return false;
        }

        public List<NUOC> GetRecord(NUOC record)
        {
            devicemanager = new QLThietBiEntities();
            IQueryable<NUOC> custQuery = devicemanager.NUOCs.AsQueryable<NUOC>();
            return custQuery.ToList();
        }

        public bool DeleteRecord(NUOC record)
        {
            throw new NotImplementedException();
        }
    }
}
